// src/post/entities/post.entity.ts
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { ScenicSpotEntity } from 'src/scenic-spot/entities/scenic-spot.entity';
import { UserEntity } from 'src/user/entities/user.entity';
import { ImageEntity } from 'src/image/entities/image.entity'; // ✅ 导入图片实体

@Entity('post')
export class PostEntity {
  @PrimaryGeneratedColumn()
  id: number;

  // ✅ 将 mediaUrl: string 替换为 ImageEntity 的关系
  @ManyToOne(() => ImageEntity)
  image: ImageEntity;

  @ManyToOne(() => ScenicSpotEntity)
  scenicSpot: ScenicSpotEntity;

  @Column({ length: 200 })
  address: string;

  @Column({ length: 200 })
  addressDescription: string;

  @Column({ length: 500 })
  idea: string;

  @Column({ length: 500 })
  environment: string;

  @Column()
  shotTime: Date;

  @ManyToOne(() => UserEntity)
  author: UserEntity;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @Column({ default: 0 })
  likeCount: number;

  @Column({ default: 0 })
  favoriteCount: number;

  @Column({ default: 0 })
  commentCount: number;
}
